package exception;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FinallyDemo4 {
    public static void main(String[] args) {


        FileOutputStream fos = null;
        try {
            try {
                fos = new FileOutputStream("note.txt");
                fos.write(1);
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                try {
                    if (fos != null) {
                        fos.close();
                    }
                } catch (IOException e) {
                    System.out.println("关闭失败");
                }
            }
        } catch (RuntimeException e) {
            throw new RuntimeException(e);
        }
    }
}